﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using H2.Streams;

namespace Mystery
{
    public class TriggerVolume
    {
        public const int Size = 68;
        public const int Offset = 264;

        int Name; //StringID
        short ScriptObjectIndex;
        
        byte[] Padding = new byte[2];

        int NodeName; //StringID

        byte[] Padding2 = new byte[28];

        public float PositionX;
        public float PositionY;
        public float PositionZ;

        public float ExtentsX;
        public float ExtentsY;
        public float ExtentsZ;

        byte[] Padding3 = new byte[4];

        public void ReadFrom(BaseStream stream)
        {
            Name = stream.ReadInt32();
            ScriptObjectIndex = stream.ReadInt16();
            Padding = stream.ReadBytes(Padding.Length);
            NodeName = stream.ReadInt32();
            Padding2 = stream.ReadBytes(Padding2.Length);
            PositionX = stream.ReadFloat();
            PositionY = stream.ReadFloat();
            PositionZ = stream.ReadFloat();
            ExtentsX = stream.ReadFloat();
            ExtentsY = stream.ReadFloat();
            ExtentsZ = stream.ReadFloat();
            Padding3 = stream.ReadBytes(Padding3.Length);
        }

        public void WriteTo(BaseStream stream)
        {
            stream.Write(Name);
            stream.Write(ScriptObjectIndex);
            stream.Write(Padding);
            stream.Write(NodeName);
            stream.Write(Padding2);
            stream.Write(PositionX);
            stream.Write(PositionY);
            stream.Write(PositionZ);
            stream.Write(ExtentsX);
            stream.Write(ExtentsY);
            stream.Write(ExtentsZ);
            stream.Write(Padding3);
        }
    }
}
